package com.test.nnooolwdeaer.activity_fragment_wooden.fragment_wooden;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.test.nnooolwdeaer.R;
import com.test.nnooolwdeaer.activity_fragment_wooden.base_wooden.BaseLoanFragment_wooden;
import com.test.nnooolwdeaer.bean_wooden.StaticVariate_wooden;
import com.test.nnooolwdeaer.bean_wooden.user_info_wooden.LoanLimitInfo_wooden;
import com.test.nnooolwdeaer.util_wooden.StringUtil_wooden;
import com.test.nnooolwdeaer.util_wooden.http_wooden.HttpManager_wooden;


public class LoanMainFragment_wooden extends BaseLoanFragment_wooden {

    private TextView loanAmountTv_wooden;
    private TextView limit1Tv,limit2Tv;

    public boolean isRefresh_wooden = false;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_loan_main_wooden, container, false);
        init_wooden(view);
        return view;
    }

    @SuppressLint("SetTextI18n")
    private void init_wooden(View view) {
        loanAmountTv_wooden = view.findViewById(R.id.fragment_loan_main_tv_loan_amount);
        limit1Tv = view.findViewById(R.id.fragment_loan_main_tv_limit_1);
        limit2Tv = view.findViewById(R.id.fragment_loan_main_tv_limit_2);
        String moneyUnit = StaticVariate_wooden.getMoneyUnit_wooden();
//        limit1Tv.setText(moneyUnit + " 800,000");
//        limit2Tv.setText(moneyUnit + " 1,000,000");

        view.findViewById(R.id.fragment_loan_main_btn_refresh_status).setOnClickListener(v -> {
            isRefresh_wooden = true;
            HttpManager_wooden.getInstance_wooden().requestUserProcess_wooden();
        });

        view.findViewById(R.id.fragment_loan_main_layout_apply_btn).setOnClickListener(v -> {
            HttpManager_wooden.getInstance_wooden().saveUserBuriedPointAndUpload((this.getClass().getSimpleName() + "_CLICK").toUpperCase());
            HttpManager_wooden.getInstance_wooden().requestUserProcess_wooden();
        });

        HttpManager_wooden.getInstance_wooden().queryLoanLimit_wooden();

    }

    @SuppressLint("SetTextI18n")
    public void updateLoanAmount_wooden() {
        isRefresh_wooden = false;
        loanAmountTv_wooden.setText(StringUtil_wooden.getSafeString_wooden(StaticVariate_wooden.getMoneyUnit_wooden()).toUpperCase() + " "
                + LoanLimitInfo_wooden.getInstance_wooden().getLimitAmount_wooden());
        limit1Tv.setText(StringUtil_wooden.getSafeString_wooden(StaticVariate_wooden.getMoneyUnit_wooden()).toUpperCase() + " "
                + LoanLimitInfo_wooden.getInstance_wooden().getLimitIncreasedAmount1_wooden());
        limit2Tv.setText(StringUtil_wooden.getSafeString_wooden(StaticVariate_wooden.getMoneyUnit_wooden()).toUpperCase() + " "
                + LoanLimitInfo_wooden.getInstance_wooden().getLimitIncreasedAmount2_wooden());

    }

}